﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasertTemplates.Master" AutoEventWireup="true"
    CodeBehind="MainMarket.aspx.cs" Inherits="WebApplication.MainMarket" %>

<%@ Register TagPrefix="uc1" TagName="usermeg" Src="~/UserControl/UserMessageControl.ascx" %>
<%@ Register TagPrefix="uc1" TagName="maintab" Src="~/UserControl/MainTabControl.ascx" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            checkIsHas();
            $("#menu1_ul2").find("li").each(function (i) {
                $(this).click(function () {
                    $("#menu1_ul2").find("li").children("span").removeClass();
                    $(this).children("span").addClass("span" + (i + 1));
                    $(".country_for_area").hide();
                    $("#div" + i).show();
                });
            });

            $("#ContentPlaceHolder2_lblMessages").html('');
            $(".labelTb").find("input[type='checkbox']").click(function () { 
                 checkIsHas();              
            });

        });

      



        //选择全子项
        function selectAll(num) 
        {           
            var val = $("#ContentPlaceHolder2_CheckBox"+num).attr("checked");
            $("#ContentPlaceHolder2_CheckBoxList" + num).find("input").attr("checked", val);
             checkIsHas()
        }

        function selectAllWorld() {

            if ($("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked")) 
                {
                    $("#div_allCountry").find("input").attr("checked", 'true');
                    $("#menu1_ul2").find(".selected").css("visibility", "visible");

                }
                else {
                    $("#div_allCountry").find("input").attr("checked", '');
                    $("#menu1_ul2").find(".selected").css("visibility", "hidden");

                }          
        
         }

         //检查是否有已选项

        function checkIsHas() {
            $("#menu1_ul2").find(".selected").css("visibility", "hidden");

            for (i = 1; i < 8; i++) {
                var has = false;//判断是否有，并且是否全部被选
                var all = false;
                $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").each(function () {
                    if ($(this).attr("checked")) {
                        has = true;
                        //$("#menu1_ul2").find(".li" + i).find(".selected").css("visibility", "visible");
                        if(has&&all)
                            return false;

                    } else {
                        all = true;
                        if (has && all)
                            return false;
                        //$("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "");
                        // $("#div_allCountry").find("input").attr("checked", '');
                    }

                })

                if (has){
                    $("#menu1_ul2").find(".li" + i).find(".selected").css("visibility", "visible");
                }

                if (all) {
                    $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "");
                    $("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked", '');
                } else {
                    $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "true");
                }

            }

        }

        function GetChangeVal() {
            var addVal = "";
            var proVal = "";
            var delVal = "";
            var hiddenStr = $("#ContentPlaceHolder2_HiddenField_val").val();
            var hiddenVal = hiddenStr.substring(0, hiddenStr.length - 1).split(",");

            for (i = 0; i < 8; i++) {
                $("#ContentPlaceHolder2_CheckBoxList" + i).find("input:checked").each(function (m, n) {
                    var has = true;
                    for (j = 0; j < hiddenVal.length; j++) {
                        if (n.value == hiddenVal[j]) {
                            has = false;
                            break;
                        }
                    }
                    if (has) {
                        addVal += n.value + ",";
                    }
                    else {
                        proVal += n.value + ",";
                    }

                    var msg = $(this).next("label").text();
                });
            }
            proVal = proVal.substring(0, proVal.length - 1).split(",");

            for (i = 0; i < hiddenVal.length; i++) {
                var has = true;
                for (j = 0; j < proVal.length; j++) {
                    if (hiddenVal[i] == proVal[j]) {
                        has = false;
                        break;
                    }
                }
                if (has) {
                    delVal += hiddenVal[i] + ",";
                }
            }

            $("#ContentPlaceHolder2_HiddenFiled_add").attr("value", addVal);
            $("#ContentPlaceHolder2_HiddenFiled_del").attr("value", delVal);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <input type="hidden" value="t7" id="pageName" />
    <div class="content-title">
        <h1>
            Customer - Main Market</h1>
    </div>
    <div class="con-nav">
        <a href="Basicinformation.aspx" class="btn"><span class="ui-icon ui-icon-newwin"></span>
            Add New Customer</a>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true" runat="Server" ID="ScriptManager1" />
    <uc1:usermeg ID="usermeg" runat="server"></uc1:usermeg>
    <div class="partWrap">
        <uc1:maintab ID="maintab" runat="server" />
        <div class="clear20">
        </div>
        <div class="productWrap">
            <div class="productTitle">
            </div>
            <div class="CheckWrap">
                <div class="clear10">
                </div>
                <table cellpadding="0" cellspacing="0" class="labelTb" width="100%">
                    <tr>
                        <td colspan="3">
                            <asp:CheckBox ID="CheckBox_AllArae" onclick="selectAllWorld()" runat="server" Text="<strong>World Wide 世界各地</strong>" />
                        </td>
                    </tr>
                </table>
                <div class="clear10">
                </div>
                <ul class="menu1_ul menu2" id="menu1_ul2">
                    <li class="li1">
                        <div id="gou4" class="selected">
                            √</div>
                        <span title="4" class="span1">Africa</span></li>
                    <li class="li2">
                        <div  id="gou1"  class="selected" style="color: #ffffff;">
                            √</div>
                        <span title="1">Asia</span></li>
                    <li class="li3">
                        <div id="gou3"  class="selected" style="color: #ffffff;">
                            √</div>
                        <span title="3">Australia</span></li>
                    <li class="li4">
                        <div id="gou7"  class="selected">
                            √</div>
                        <span title="7">Europe</span></li>
                    <li class="li5">
                        <div id="gou2"  class="selected">
                            √</div>
                        <span title="2">Middle East</span></li>
                    <li class="li6">
                        <div id="gou5"  class="selected">
                            √</div>
                        <span title="5">North America</span></li>
                    <li class="li7">
                        <div id="gou6"  class="selected">
                            √</div>
                        <span title="6">South America</span></li>
                </ul>
                <div class="clear20">
                </div>
                <!-- one -->
                <%--非洲--%>
                <div id="div_allCountry">
                    <div id="div0" style="display: block;" class="country_for_area">
                        <p>
                            <asp:CheckBox onclick="selectAll('1')" ID="CheckBox1" runat="server" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList1" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--亚洲--%>
                    <div id="div1" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox2" onchange="selectAll('2')" runat="server" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList2" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--澳洲--%>
                    <div id="div2" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox3" onchange="selectAll('3')" runat="server" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList3" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--欧洲--%>
                    <div id="div3" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox4" onchange="selectAll('4')" runat="server" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList4" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--中东--%>
                    <div id="div4" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox5" runat="server" onchange="selectAll('5')" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList5" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--北美--%>
                    <div id="div5" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox6" onchange="selectAll('6')" runat="server" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList6" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                    <%--南美--%>
                    <div id="div6" style="display: none;" class="country_for_area">
                        <p>
                            <asp:CheckBox ID="CheckBox7" runat="server"  onchange="selectAll('7')" Text="<strong>All</strong>" /><br />
                        </p>
                        <asp:CheckBoxList ID="CheckBoxList7" runat="server" CssClass="labelTb" RepeatColumns="3"
                            RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
                        </asp:CheckBoxList>
                    </div>
                </div>
            </div>
        </div>
        <asp:HiddenField runat="server" ID="HiddenField_val" />
        <asp:HiddenField runat="server" ID="HiddenFiled_add" />
        <asp:HiddenField runat="server" ID="HiddenFiled_del" />
        <div class="clear20">
        </div>
    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always"
        RenderMode="Block">
        <ContentTemplate>
            <table border="0" cellspacing="0" cellpadding="0" class="btnwrap">
                <tr>
                    <td class="btnwrapl">
                        <ul class="uibtn">
                            <li>
                                <asp:LinkButton ID="LbtnSave" runat="server" OnClick="LbtnSave_Click" OnClientClick='javascript:$("#ContentPlaceHolder2_lblMessages").html("");'>Save</asp:LinkButton>
                            </li>
                        </ul>
                    </td>
                    <td class="btnwrapr">
                        <ul class="uibtn">
                            <li>
                                <asp:LinkButton ID="LbtnQuit" runat="server" OnClick="LbtnQuit_Click">Quit</asp:LinkButton>
                            </li>
                        </ul>
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                <ProgressTemplate>
                    <span style="color: Red;">提交大量的数据，服务器需要处理，请稍等...</span>
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:Label ID="lblMessages" runat="server" Text="" ForeColor="Red"></asp:Label>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
